<?php

$logueado = true;
if (!isset($_SESSION['Username'])) {
    session_destroy();
    $logueado = false;
    header("Location: index.php");
} else {


    $usuario = addslashes(htmlspecialchars($_SESSION['Username']));
    //$email = addslashes(htmlspecialchars($email));
    $con = ConnectionSecure::getInstancia();
    $con->conectar();
    $dbconn = $con->getConexion();
    $query = $dbconn->prepare("select id from usuario where Username=?");
    $query->bind_param("s", $usuario);
    if ($query->execute() == true) {
        $query->bind_result($id);
        $query->fetch();
        $con->desconectar();
        $con->conectar();
        $dbconn = $con->getConexion();
        if (isset($id) && $id > 0) {
            $rs = $dbconn->query("select * from rol_usuario where Idusuario=" . $id . "");
            $rs->data_seek(0);
            $rolUsuario = $rs->fetch_assoc();
            $con->desconectar();
        }
        else
            header("Location: index.php");
    } else {
        $con->desconectar();
        header("Location: index.php");
    }
}
?>